package com.tanran.taolijin.model;

import com.tanran.taolijin.util.TextUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

/**
 * 淘宝账号类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "taobao_account")
public class TaobaoAccount {
    @Id
    private String uId;
    private String sId;
    private String nickName;
    private String mH5Tk;
    private String time;
    private String token;
    private String expiredTime;
    @Column(columnDefinition="text")
    private String cookies;
    private String noticeChat;
    private String qrUrl;


    public void setCookies(String cookies) {
        if(cookies.indexOf("unb")!=-1){
            setUId(TextUtil.getSubString(cookies,"unb=",";"));
        }
        if(cookies.indexOf("cookie2")!=-1){
            setSId(TextUtil.getSubString(cookies,"cookie2=",";"));
        }
        if(cookies.indexOf("_m_h5_tk")!=-1){
            setMH5Tk(TextUtil.getSubString(cookies,"_m_h5_tk=","_"));
        }
        this.cookies = cookies;
    }

    public String getuId() {
        if (uId==null){
           return "";
        }
        return uId;
    }

    public String getsId() {
        if (sId==null){
            return "";
        }
        return sId;
    }

    public String getmH5Tk() {
        if (mH5Tk==null){
            return "";
        }
        return mH5Tk;
    }

    public String getCookies() {
        if (cookies==null){
            return "";
        }
        return cookies;
    }

    public String getTime() {
        if (time==null){
            return "";
        }
        return time;
    }

    public String getToken() {
        if (token==null){
            return "";
        }
        return token;
    }

    public String getExpiredTime() {
        if (expiredTime==null){
            return "";
        }
        return expiredTime;
    }

    public String getNoticeChat() {
        if (noticeChat==null){
            return "";
        }
        return noticeChat;
    }

    public String getQrUrl() {
        if (qrUrl==null){
            return "";
        }
        return qrUrl;
    }
}
